// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import store from './store'
import router from './router'
import VTooltip from 'v-tooltip'
import "@/config/axios.conf"
// import '@/static/js/plugins/jquery-vender'
import '@/static/js/plugins/jquery.slimscroll'
// import 'bootstrap'
// import 'bootstrap/dist/css/bootstrap.css'

import '@/static/css/style.css'
import '@/static/css/colors/blue.css'
import 'animate.css'

import 'jquery-toast-plugin'
import 'jquery-toast-plugin/dist/jquery.toast.min.css'

import 'dropify/dist/css/dropify.min.css'

import {auth} from '@/api/auth'
import '@/filters'
import '@/mixins/global'

Vue.use(VTooltip)
Vue.config.productionTip = false

import CheckboxRadio from 'vue-checkbox-radio';
Vue.use(CheckboxRadio);

window.isDev = process.env.NODE_ENV === 'development' ? true : false

function init() {
    /* eslint-disable no-new */
    new Vue({
        el: '#app',
        router,
        store,
        components: {App},
        template: '<App/>',
    })
}

// 判断是否已登录
auth().then(function (response) {
    store.commit('SET_TOKEN', response.data['auth'])
    store.commit('SET_USER', response.data['username'])
    store.commit('SET_GROUP', response.data['group_id'])
    window.state = store.state
    init()
}).catch(function () {
    store.commit('SET_TOKEN', null)
    store.commit('SET_USER', null)
    store.commit('SET_GROUP', null)
    init()
})
